
var WindWindow = new Object();

WindWindow.setTitle = function (title) {
	document.title = title;
}

WindWindow.addView = function (view) {
	view.setParentView(null);
	var div = view.render();
	document.body.appendChild(div);
	view.applyFullscreenToHtmlElement();
	view.applyCenteredToHtmlElement();
}

WindWindow.removeView = function (view) {
	var div = view.getHtmlElement();
	if(div.parentNode!=null) {
		div.parentNode.removeChild(div);
	}
}

WindWindow.getViewById = function(id) {
	var view = null;
	var htmlElement = document.getElementById(id);
	if(htmlElement!=null) {
		if(htmlElement.getView!=null) {
			view = htmlElement.getView();
		}
	}
	return view;
}

WindWindow.updateView = function (oldView, newView) {
	var oldDiv = oldView.getHtmlElement();
	var newDiv = newView.render();
	oldDiv.style.display = "none";
	oldDiv.parentNode.insertBefore(newDiv, oldDiv);
	oldDiv.parentNode.removeChild(oldDiv);
}


WindWindow.getWindowHeight = function() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

WindWindow.getWindowWidth = function() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
        Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
        Math.max(D.body.clientWidth, D.documentElement.clientWidth)
    );
}